package com.kxr.day09.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 界面和地址映射
 */
@WebServlet(urlPatterns = "/jingmao")
public class JingmaoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 加一些业务逻辑处理
        // 跳转到jsp页面,跳转到了jingmao.jsp
        // 加载数据库的内容，让他显示到界面
        // 后端获取前端的请求参数
        String school = req.getParameter("school");
        String name = "张三";
        // 添加界面可以得到的数据，后端向前端传递数据
        req.setAttribute("name",name);
        req.setAttribute("age",18);
        req.setAttribute("school",school);
        // 跳转到对应的jsp
        req.getRequestDispatcher("jingmao.jsp").forward(req,resp);
    }
}
